#include "code/inc/lcd_queue.h"
#include "stdio.h"
#include "string.h"

void  lcdqueue_init(struct queue *queue)
{
   memset((uint8 *)queue,0,sizeof(queue));
}
uint8 lcdqueue_sendmsg(struct queue *queue,const char *buf)
{
    if(queue->head == ((queue->tail +1)%LCDQUEUEMAX))//队列已满
    {
        return 0;
    }

    if(strlen(buf) >=LCDMSGMAX)
    {
        return 0;
    }

    uint32 pos = queue->tail;
    sprintf((queue->_queuelist+pos)->list,"%s",buf);
    queue->tail = (queue->tail+1)%LCDQUEUEMAX;
    return 1;
}
uint8 lcdqueue_recvmsg(struct queue *queue,char *buf)
{
    if(queue->head == queue->tail)//队列为空
    {
         return 0;
    }
    uint32 pos = queue->head;
    sprintf(buf,"%s",(queue->_queuelist+pos)->list);
    queue->head = (queue->head+1)%LCDQUEUEMAX;
    return 1;
}
